package com.monitor.service.impl;

import com.monitor.dao.SettingDao;
import com.monitor.po.Setting;
import com.monitor.service.SettingService;

public class SettingServiceImpl implements SettingService {
	
	private SettingDao settingDao;

	@Override
	public String isUploadSms() throws Exception {
		return settingDao.getValue(KEY_UPLOAD_SMS, UPLOAD_TRUE_VAL);
	}

	@Override
	public String isUploadCallLog() throws Exception {
		return settingDao.getValue(KEY_UPLOAD_CALLLOG, UPLOAD_TRUE_VAL);
	}

	@Override
	public String isUploadLocation() throws Exception {
		return settingDao.getValue(KEY_UPLOAD_LOCATION, UPLOAD_TRUE_VAL);
	}

	@Override
	public boolean set(String uploadSms, String uploadCalllog, String uploadLocation) throws Exception {
		settingDao.updateSetting(new Setting(KEY_UPLOAD_CALLLOG, uploadCalllog));
		settingDao.updateSetting(new Setting(KEY_UPLOAD_LOCATION, uploadLocation));
		settingDao.updateSetting(new Setting(KEY_UPLOAD_SMS, uploadSms));
		return true;
	}

	public SettingDao getSettingDao() {
		return settingDao;
	}

	public void setSettingDao(SettingDao settingDao) {
		this.settingDao = settingDao;
	}

}
